Win32: Fix _gdk_windowing_window_at_pointer to correctly return a toplevel
authorPeter Clifton <pcjc2@cam.ac.uk>
Sat, 10 Sep 2011 15:30:56 +0000 (16:30 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 10 Nov 2011 16:40:50 +0000 (17:40 +0100)
commit05e982a11a7e69c93d5cba42847f838bc7e108d5
tree51b7a6ef3f66d8acecb5ca1fa693e8950d488555
parentf9d8f9758bfe1417416e0b2bbea955f1cee75674
Win32: Fix _gdk_windowing_window_at_pointer to correctly return a toplevel

Commit 5ebb32d1ffa23241d562fb4d5be02bc6f156b515 didn't add the correct
code to find the toplevel window. The WindowFromPoint() function does
not return the toplevel window in the hierarchy, it returns the deepest
non-disabled, non-invisible child. As we don't use invisible or disabled
windows, we don't actually need to use the ChildWindowFromPoint walk for
the non get_toplevel case, so we can remove that code path.

To find a toplevel, we need to start from the desktop and work up, using
ChildWindowFromPointEx (to ignore invisible and disabled windows). If we
don't ignore invisible and disabled windows (as is the case with the
ChildWindowFromPoint call, we are liable to get returns of hidden or
disabled children of the desktop which don't belong to us, but notionally
occupy the same area under the pointer.

An alternative might be to start our walk with one of the children of the
desktop owned by our process and thread - which we can enumerate using,
the EnumThreadWindows call, or (presumably) determine internally. This
would not work when we are inside a GtkSocket though, as the children of
the desktop would belong to the process owning the GtkPlug - we would
have to rely on our own list of windows.

For correctness, this commit adds tests to ensure that we don't try to
return either x or y window coordinates if that corresponding pointer is
NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=658842
gdk/win32/gdkdevice-win32.c